//
//  NumberListensViewController.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/2/6.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "NumberListensViewController.h"
#import "TitleView.h"
@interface NumberListensViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation NumberListensViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    TitleView *topView=[[TitleView alloc] initWithFrame:CGRectMake(0, 0, _mainW, NAV_HEIGHT)];
    topView.intrinsicContentSize = CGSizeMake(_mainW, NAV_HEIGHT);
    self.navigationItem.titleView = topView;
    
    UILabel *label=[UILabel new];
    [topView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(-15);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(23);
    }];
    label.text=@"收听人数";
    label.font=[UIFont systemFontOfSize:14];
    label.textColor=ColorWithRGB(49, 49, 49);
    
    
    UIImageView *imageView=[UIImageView new];
    [topView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(-25);
        make.width.height.mas_equalTo(17);
        make.centerY.mas_equalTo(12);
    }];
    imageView.image=[UIImage imageNamed:@"收听人数"];
    
    UILabel *label2=[UILabel new];
    [topView addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageView.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(imageView);
    }];
    label2.text=[NSString stringWithFormat:@"%ld",_tableArr.count];
    label2.font=[UIFont systemFontOfSize:14];
    label2.textColor=ColorWithRGB(49, 49, 49);
    
    
    BaseTableView *tableView=[BaseTableView new];
    [self.view addSubview:tableView];
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(NAV_HEIGHT);
    }];
    tableView.delegate=self;
    tableView.dataSource=self;
    tableView.backgroundColor=_LightGrey;
    
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _tableArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BaseTableViewCell *cell=[[BaseTableViewCell alloc] init];
    NSDictionary *Dic=_tableArr[indexPath.row];
    cell.backgroundColor=[UIColor whiteColor];
    
    UIView *view=[UIView new];
    [cell addSubview:view];
    [view setFrame:CGRectMake(0, 0, _mainW, 100)];
    
    UIImageView *imageView=[UIImageView new];
    [view addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.centerY.mas_equalTo(0);
        make.width.height.mas_equalTo(60);
    }];
    imageView.layer.cornerRadius=30;
    imageView.layer.masksToBounds=YES;
    NSString *news_cover=[Dic objectForKey:@"user_icon"];
    news_cover=[NSString stringWithFormat:@"%@%@",_addressUrl,news_cover];
    [imageView sd_setImageWithURL:[NSURL URLWithString:news_cover]];
    
    UILabel *labele=[UILabel new];
    [view addSubview:labele];
    [labele mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageView.mas_right).mas_equalTo(15);
        make.centerY.mas_equalTo(-15);
    }];
    labele.text=[Dic objectForKey:@"user_nickname"];
    labele.textColor=ColorWithRGB(49, 49, 49);
    labele.font=[UIFont systemFontOfSize:17];
    
    
    UILabel *timeLabel=[UILabel new];
    [view addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(labele);
        make.centerY.mas_equalTo(15);
    }];
    NSNumber *time=[Dic objectForKey:@"order_pay_time"];
    timeLabel.text=[ZQTools changeTimeCuo:@"YYYY-MM-dd HH:mm:ss" :[NSString stringWithFormat:@"%@",time]];
    timeLabel.font=[UIFont systemFontOfSize:15];
    timeLabel.textColor=ColorWithRGB(149, 149, 149);
    
    
    UILabel *moneyLabel=[UILabel new];
    [view addSubview:moneyLabel];
    [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-20);
        make.centerY.mas_equalTo(0);
    }];
    NSNumber *order_money=[Dic objectForKey:@"order_money"];
    moneyLabel.text=[NSString stringWithFormat:@"¥%@",order_money];
    moneyLabel.textColor=_backgroundColor;
    moneyLabel.font=[UIFont systemFontOfSize:18];
    
//    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
